package org.jeecg.modules.job.ums.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.jeecg.modules.job.ums.entity.UmsMemberRole;
import org.jeecg.modules.job.ums.mapper.UmsMemberRoleMapper;
import org.jeecg.modules.job.ums.service.IUmsMemberRoleService;
import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

/**
 * @Description: 会员公司关系
 * @Author: jeecg-boot
 * @Date:   2022-12-18
 * @Version: V1.0
 */
@Service
public class UmsMemberRoleServiceImpl extends ServiceImpl<UmsMemberRoleMapper, UmsMemberRole> implements IUmsMemberRoleService {

    @Override
    public boolean saveOrUpdateRole(UmsMemberRole role) {
        UmsMemberRole result=this.getOne(new QueryWrapper<>(role));
        if (result!=null){
            role.setId(result.getId());
            return this.updateById(role);
        }else{
            return this.save(role);
        }
    }

    @Override
    public UmsMemberRole getMemberRole(String memberId) {
        return this.getOne(new QueryWrapper<UmsMemberRole>().eq("member_id",memberId));
    }

    @Override
    public String getCompanyId(String memberId) {
        return getMemberRole(memberId).getCompanyId();
    }
}
